/** lock.d - 
  Written in the D programming language 1.0

Authors:	Wei Li <oldrev@gmail.com>
Copyright:	Copyright (c) 2007 by Wei Li.
License:	BSD
*/

module dotmars.threading.lock;

import dotmars.base.time;
import dotmars.base.stdtypes;

interface ILockable
{
	void lock();
	bool lock(uint timeout);
	bool lock(TimeSpan ts);
	bool tryLock();
	void unlock();
}

abstract class Lockable : ILockable, IDisposable
{
	public abstract void lock();
	public abstract bool lock(uint timeout);
	public abstract bool tryLock();
	public abstract void unlock();
	public abstract void close();

	public final override bool lock(TimeSpan ts)
	in 
	{
		assert(ts.ticks >= 0);
	}
	body 
	{
		return lock(ts.milliseconds);	
	}
}
